<template>
  <div>
    <mt-header title="购买会籍" id="ji">
      <mt-button icon="back" slot="left"></mt-button>
    </mt-header>
    <div class="co">
      <div class="ko">
        <div class="ei">欢迎购买山姆会籍</div>
        <div class="li">请填写您的基础信息</div>
      </div>
      <div id="ti">
        <input
          type="text"
          style="
            border: 0;
            border-bottom: 0 solid black;
            background: 0;
            outline: none;
          "
          placeholder="手机号"
          class="sj"
          v-model="mphone"
        />
        <hr />
        <input
          type="text"
          style="
            border: 0;
            border-bottom: 0 solid black;
            background: 0;
            outline: none;
          "
          placeholder="您的姓名"
          class="sj"
          v-model="mname"
        />
        <hr />
      </div>
      <van-button type="primary" size="large" @click="getvipshop"
        >下一步</van-button
      >
    </div>
  </div>
</template>
<script>
import { MessageBox } from "mint-ui";
export default {
  data() {
    return {
      mphone: "",
      mname: "",
    };
  },
  methods: {
    getvipshop() {
      let phone = /^1[3-9]\d{9}$/;
      let name = /^[\u4e00-\u9fa5]{2,16}$/;
      if (name.test(this.mname) && phone.test(this.mphone)) {
        console.log("验证成功");
        this.axios
          .post("/user/vipreg", `mname=${this.mname}&mphone=${this.mphone}`)
          .then((res) => {
            if (res.data.code == 200) {
              MessageBox.alert("注册成功").then(function () {
                window.location.href = "/mymessage";
              });
            } else if (res.data.code == 201) {
              MessageBox.alert("该用户已注册会员");
            } else if (res.data.code == 202) {
              MessageBox.alert("请输入您现在登录所使用的手机号");
            }
          });
      } else {
        this.$toast("提示:" + "请输入正确的手机号或名字");
      }
    },
    getvipto() {},
  },
};
</script>
<style scoped>
.sj {
  margin-top: 5vw;
}
.ei {
  font-size: 14px;
  text-align: left;
  margin-top: 5vw;
}
.li {
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  margin-top: 5vw;
}
#ji {
  font-size: 18px;
  font-weight: bold;
  background-color: #fff;
  color: #000;
}
.ti {
  text-align: left;
}
.co {
  width: 90vw;
  margin: auto;
  padding-top: 5vw;
}
.yi {
  border-style: none;
  width: 90vw;
  background-color: rgb(249, 227, 206);
  color: #fff;
  padding: 3vw;
  margin-top: 10vw;
}
</style>
